﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace RiskMan.DataClass.AlfaDirectFolder
{
    /// <summary>
    /// ТАБЛИЦА «ORDERS» - ЗАЯВКИ
    /// Ключевое поле: ord_no
    /// </summary>
    public class Orders : INotifyPropertyChanged
    {
        #region Private

        private long _ordNo;
        private string _accCode;
        private string _status;
        private string _bS;
        private double _price;
        private int _qty;
        private int _rest;
        private DateTime _tsTime;
        private string _comments;
        private string _placeCode;
        private string _pCode;
        private double _stopPrice;
        private string _blank;
        private double _actvGrowPrice;
        private double _actvDownPrice;
        private DateTime _actvTime;
        private int _actvKldOrderNo;
        private int _actvStldOrderNo;
        private double _dropGrowPrice;
        private double _dropDownPrice;
        private DateTime _dropTime;
        private double _volume;
        private double _netValue;
        private double _trailingLevel;
        private double _trailingSlippage;
        private string _teaty;
        private double _initPrice;
        private string _ordType;
        private string _accName;
        private string _statusDesc;
        private string _typeDesc;
        private string _ansiName;
        private string _placeName;
        private string _firmName;

        #endregion

        #region Public

        /// <summary>
        /// Номер.
        /// </summary>
        public long OrdNo
        {
            get { return _ordNo; }
            set
            {
                if (_ordNo != value)
                    _ordNo = value;

                RaisePropertyChanged("OrdNo");
            }
        }
        /// <summary>
        /// Портфель.
        /// </summary>
        public string AccCode
        {
            get { return _accCode; }
            set
            {
                if (_accCode != value)
                    _accCode = value;

                RaisePropertyChanged("AccCode");
            }
        }
        /// <summary>
        /// Статус.
        /// </summary>
        public string Status
        {
            get { return _status; }
            set
            {
                if (_status != value)
                    _status = value;

                RaisePropertyChanged("Status");
            }
        }
        /// <summary>
        /// Покупка/продажа («B» - покупка, «S» - продажа).
        /// </summary>
        public string BS
        {
            get { return _bS; }
            set
            {
                if (_bS != value)
                    _bS = value;

                RaisePropertyChanged("BS");
            }
        }
        /// <summary>
        /// Цена.
        /// </summary>
        public double Price
        {
            get { return _price; }
            set
            {
                if (_price != value)
                    _price = value;

                RaisePropertyChanged("Price");
            }
        }
        /// <summary>
        /// Количество.
        /// </summary>
        public int Qty
        {
            get { return _qty; }
            set
            {
                if (_qty != value)
                    _qty = value;

                RaisePropertyChanged("Qty");
            }
        }
        /// <summary>
        /// Остаток
        /// </summary>
        public int Rest
        {
            get { return _rest; }
            set
            {
                if (_rest != value)
                    _rest = value;

                RaisePropertyChanged("Rest");
            }
        }
        /// <summary>
        /// Время торговой системы.
        /// </summary>
        public DateTime TsTime
        {
            get { return _tsTime; }
            set
            {
                if (_tsTime != value)
                    _tsTime = value;

                RaisePropertyChanged("TsTime");
            }
        }
        /// <summary>
        /// Комментарии.
        /// </summary>
        public string Comments
        {
            get { return _comments; }
            set
            {
                if (_comments != value)
                    _comments = value;

                RaisePropertyChanged("Comments");
            }
        }
        /// <summary>
        /// Код рынка.
        /// </summary>
        public string PlaceCode
        {
            get { return _placeCode; }
            set
            {
                if (_placeCode != value)
                    _placeCode = value;

                RaisePropertyChanged("PlaceCode");
            }
        }
        /// <summary>
        /// Код актива.
        /// </summary>
        public string PCode
        {
            get { return _pCode; }
            set
            {
                if (_pCode != value)
                    _pCode = value;

                RaisePropertyChanged("PCode");
            }
        }
        /// <summary>
        /// Стоп цена.
        /// </summary>
        public double StopPrice
        {
            get { return _stopPrice; }
            set
            {
                if (_stopPrice != value)
                    _stopPrice = value;

                RaisePropertyChanged("StopPrice");
            }
        }
        /// <summary>
        /// Тип заявки.
        /// </summary>
        public string Blank
        {
            get { return _blank; }
            set
            {
                if (_blank != value)
                    _blank = value;

                RaisePropertyChanged("Blank");
            }
        }
        /// <summary>
        /// Активировать, если цена вырастет.
        /// </summary>
        public double ActvGrowPrice
        {
            get { return _actvGrowPrice; }
            set
            {
                if (_actvGrowPrice != value)
                    _actvGrowPrice = value;

                RaisePropertyChanged("ActvGrowPrice");
            }
        }        
        /// <summary>
        /// Активировать, если цена упадет.
        /// </summary>
        public double ActvDownPrice
        {
            get { return _actvDownPrice; }
            set
            {
                if (_actvDownPrice != value)
                    _actvDownPrice = value;

                RaisePropertyChanged("ActvDownPrice");
            }
        }
        /// <summary>
        /// Активировать, когда наступит время.
        /// </summary>
        public DateTime ActvTime
        {
            get { return _actvTime; }
            set
            {
                if (_actvTime != value)
                    _actvTime = value;

                RaisePropertyChanged("ActvTime");
            }
        }
        /// <summary>
        /// Активировать, если отменится заявка.
        /// </summary>
        public int ActvKldOrderNo
        {
            get { return _actvKldOrderNo; }
            set
            {
                if (_actvKldOrderNo != value)
                    _actvKldOrderNo = value;

                RaisePropertyChanged("ActvKldOrderNo");
            }
        }
        /// <summary>
        /// Активировать, если выполнится заявка.
        /// </summary>
        public int ActvStldOrderNo
        {
            get { return _actvStldOrderNo; }
            set
            {
                if (_actvStldOrderNo != value)
                    _actvStldOrderNo = value;

                RaisePropertyChanged("ActvStldOrderNo");
            }
        }
        /// <summary>
        /// Отменить, если цена вырастет.
        /// </summary>
        public double DropGrowPrice
        {
            get { return _dropGrowPrice; }
            set
            {
                if (_dropGrowPrice != value)
                    _dropGrowPrice = value;

                RaisePropertyChanged("DropGrowPrice");
            }
        }
        /// <summary>
        /// Отменить, если цена упадет.
        /// </summary>
        public double DropDownPrice
        {
            get { return _dropDownPrice; }
            set
            {
                if (_dropDownPrice != value)
                    _dropDownPrice = value;

                RaisePropertyChanged("DropDownPrice");
            }
        }
        /// <summary>
        /// Отменить, когда наступит время.
        /// </summary>
        public DateTime DropTime
        {
            get { return _dropTime; }
            set
            {
                if (_dropTime != value)
                    _dropTime = value;

                RaisePropertyChanged("DropTime");
            }
        }
        /// <summary>
        /// Сумма заявки.
        /// </summary>
        public double Volume
        {
            get { return _volume; }
            set
            {
                if (_volume != value)
                    _volume = value;

                RaisePropertyChanged("Volume");
            }
        }
        /// <summary>
        /// Нетто.
        /// </summary>
        public double NetValue
        {
            get { return _netValue; }
            set
            {
                if (_netValue != value)
                    _netValue = value;

                RaisePropertyChanged("NetValue");
            }
        }
        /// <summary>
        /// Уровень для следящего стопа.
        /// </summary>
        public double TrailingLevel
        {
            get { return _trailingLevel; }
            set
            {
                if (_trailingLevel != value)
                    _trailingLevel = value;

                RaisePropertyChanged("TrailingLevel");
            }
        }
        /// <summary>
        /// Проскальзывание для следящего стопа.
        /// </summary>
        public double TrailingSlippage
        {
            get { return _trailingSlippage; }
            set
            {
                if (_trailingSlippage != value)
                    _trailingSlippage = value;

                RaisePropertyChanged("TrailingSlippage");
            }
        }
        /// <summary>
        /// Счет.
        /// </summary>
        public string Teaty
        {
            get { return _teaty; }
            set
            {
                if (_teaty != value)
                    _teaty = value;

                RaisePropertyChanged("Teaty");
            }
        }
        /// <summary>
        /// Начальная цена стопа.
        /// </summary>
        public double InitPrice
        {
            get { return _initPrice; }
            set
            {
                if (_initPrice != value)
                    _initPrice = value;

                RaisePropertyChanged("InitPrice");
            }
        }
        /// <summary>
        /// Тип заявки.
        /// </summary>
        public string OrdType
        {
            get { return _ordType; }
            set
            {
                if (_ordType != value)
                    _ordType = value;

                RaisePropertyChanged("OrdType");
            }
        }
        /// <summary>
        /// Название портфеля.
        /// </summary>
        public string AccName
        {
            get { return _accName; }
            set
            {
                if (_accName != value)
                    _accName = value;

                RaisePropertyChanged("AccName");
            }
        }
        /// <summary>
        /// Описание статуса заявки.
        /// </summary>
        public string StatusDesc
        {
            get { return _statusDesc; }
            set
            {
                if (_statusDesc != value)
                    _statusDesc = value;

                RaisePropertyChanged("StatusDesc");
            }
        }
        /// <summary>
        /// Описание типа заявки.
        /// </summary>
        public string TypeDesc
        {
            get { return _typeDesc; }
            set
            {
                if (_typeDesc != value)
                    _typeDesc = value;

                RaisePropertyChanged("TypeDesc");
            }
        }
        /// <summary>
        /// Короткое название.
        /// </summary>
        public string AnsiName
        {
            get { return _ansiName; }
            set
            {
                if (_ansiName != value)
                    _ansiName = value;

                RaisePropertyChanged("AnsiName");
            }
        }
        /// <summary>
        /// Название рынка.
        /// </summary>
        public string PlaceName
        {
            get { return _placeName; }
            set
            {
                if (_placeName != value)
                    _placeName = value;

                RaisePropertyChanged("PlaceName");
            }
        }
        /// <summary>
        /// Название контрагента.
        /// </summary>
        public string FirmName
        {
            get { return _firmName; }
            set
            {
                if (_firmName != value)
                    _firmName = value;

                RaisePropertyChanged("FirmName");
            }
        }


        #endregion

        #region event PropertyChangedEventHandler

        public event PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion
    }
}
